<template>
  <div>
    <template>
      <el-table
        ref="multipleTable"
        :data="this.$parent._data.arr"
        tooltip-effect="dark"
        style="width: 100%; height: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column prop="ID" label="用户ID" width="150">
        </el-table-column>
        <el-table-column prop="name" label="微信昵称" width="120">
        </el-table-column>
        <el-table-column prop="phone" label="会员手机" width="100">
        </el-table-column>
        <el-table-column prop="price" label="消费金额" width="80">
        </el-table-column>
        <el-table-column prop="number" label="订单数量" width="70">
        </el-table-column>
        <el-table-column prop="vip" label="会员等级" width="70">
        </el-table-column>
        <el-table-column label="上次消费日期" width="120">
          <template slot-scope="scope">{{ scope.row.date }}</template>
        </el-table-column>
        <el-table-column prop="disable" label="禁用账户" width="120">
          <el-switch
            v-model="value"
            active-color="#13ce66"
            inactive-color="#ff4949"
          >
          </el-switch>
        </el-table-column>
        <el-table-column prop="handle" label="操作">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
              >编辑</el-button
            >
            <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.row.ID)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </template>
  </div>
</template>

<script>
import { deleStudentApi } from "../../../api/StudentApi";
export default {
  // props:['arr']
  // tableData: [],
  // mounted(){
  //  this.tableData = this.$parent._data.arr
  //  console.log(this.tableData);
  // },
  data() {
    return {
      value: true,
        checkAll: false,
      tableData: [
        {
          ID: "",
          name: "",
          phone: "",
          price: "",
          number: "",
          vip: "",
          date: "",
          disable: false,
          address: "",
        },
      ],
      multipleSelection: [],
    };
  },

  methods: {
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(id) {
      deleStudentApi({ id: id }).then((res) => {
        console.log(res);
        this.$parent.getStudentData();
      });
    },
  },
};
</script>

<style lang = 'less' scoped>
</style>